package pl.edu.agh.gt.util;

import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

import org.apache.log4j.Logger;

public class Utils {

	private final static Logger log = Logger.getLogger(Utils.class);

	public static <T> List<T> removeDuplicatesFromList(List<T> list, Class<T> c) {

		if(list.isEmpty())
			return list;
		
		List<T> dups = new LinkedList<T>();
		
		ListIterator<T> it = list.listIterator();
		T next = it.next();
		
		while( it.hasNext() ) {
			T obj = next;
			if(!it.hasNext())
				break;
			next = it.next();
			if(obj.equals(next)) {
				dups.add(next);
				it.remove();
				next = obj;
			}
		}
		
		return dups;
	}
}
